﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UserSelector.ascx.cs"
    Inherits="NetDon.OA.Portal.Controls.UserSelector" %>
<%@ Register TagPrefix="uc2" TagName="requiredmark" Src="~/Controls/RequiredMark.ascx" %>
<%@ Import Namespace="NetDon.OA.Portal" %>
<asp:TextBox ID="txtUsers" runat="server" MaxLength="50" Width="180px" Text='<%# GetUsers(Eval("UserIds").ToString()) %>'></asp:TextBox>
<asp:ImageButton ID="btnSelectUser" runat="server" SkinID="SelectUser" OnClientClick="selectUser();return false;" />
<asp:HiddenField ID="fieldUserId" runat="server" Value='<%# Bind("UserIds") %>' />
<uc2:requiredmark ID="RequiredMark4" runat="server" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtUsers"
    Display="None" ErrorMessage="请选择人员" SetFocusOnError="True"></asp:RequiredFieldValidator>
<script language="javascript" type="text/javascript">
    function usersChanged(evt) {
        PageMethods.GetAdminUserId($text($get('<%=txtUsers.ClientID %>')), function (result) {
            if (!String.isNullOrEmpty(result)) {
                $text($get('<%=fieldUserId.ClientID %>'), result);
            } else {
                $text($get('<%=fieldUserId.ClientID %>'), String.empty);
                $text($get('<%=txtUsers.ClientID %>'), String.empty);
                $alert('The user name cannot be found in system.', function () {
                    $get('<%=txtUsers.ClientID %>').focus();
                });
            }
        })
    }

    function pageLoad() {
        $addHandler($get('<%=txtUsers.ClientID %>'), 'change', usersChanged);
    }

    function selectUser() {
        $dialog('<%=ResolveUrl("~/Controls/Selector.aspx") %>', { width: 740, height: 500 }, function (result) {
            if (result) {
                $text($get('<%=txtUsers.ClientID %>'), result.LoginName);
                $text($get('<%=fieldUserId.ClientID %>'), result.UserId);
            }
        })
    }
</script>